﻿using System;
using System.Diagnostics.Contracts;

namespace Eirene.Core.Model
{
    /// <summary>
    /// Represents a status for an <see cref="Item"/>.
    /// </summary>
    public class Status
    {
        #region Fields

        private string _name;

        #endregion

        #region Constructors

        public Status(string name)
        {
            Contract.Requires(!String.IsNullOrEmpty(name));
            _name = name;
        }

        #endregion

        #region Properties

        public string Name
        {
            get
            {
                Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<string>()));
                return _name;
            }

            set
            {
                Contract.Requires(!String.IsNullOrEmpty(value));
                if (_name != value)
                {
                    _name = value;
                }
            }
        }

        #endregion

        #region Impl

        [ContractInvariantMethod]
        private void ObjectInvariant()
        {
            Contract.Invariant(!String.IsNullOrEmpty(_name));
        }

        #endregion
    }
}
